package com.acme.bankapp.service.bank;

import com.acme.bankapp.domain.bank.Account;
import com.acme.bankapp.domain.bank.Bank;
import com.acme.bankapp.domain.bank.Client;
import com.acme.bankapp.exceptions.bank.ClientsExistsException;

public class BankService {
    public Bank createNewBank() {
        return new Bank();
    }

    public Client addClient(Bank bank, Client client) throws ClientsExistsException {
        return bank.addClient(client);
    }

    public void printBalance(Bank bank) {
        StringBuffer buffer = new StringBuffer();
        for (Client c : bank.getClients()) {
            for (Account acc : c.getAccounts()) {
                buffer.append(acc).append("\n");
            }
        }
        System.out.println(buffer);
    }

    public void printMaximumAmountToWithdraw(Bank bank) {
        for (Client c : bank.getClients()) {
            for (Account acc : c.getAccounts()) {

                System.out.println(acc);
            }
        }
    }

}
